<?php
 include_once("./tool_string.php");
 include_once("./class_segment.php");
 require "./class_chunker.php";

 require "../document/class_document.php";
 require "../document/class_document_xml.php";
 require "../files/tool_files_dirs.php";
 require "../misc/class_tag.php";

 require "../tree/class_tree.php";
 require "../tree/class_tree_xhtml.php";
 require "../tree/class_structure.php";
 require "../tree/tool_tree.php";

 require "../array/tool_array.php";

 $document=new document_xml();
 $document->__init("../xml/europa/celex_IP-04-901.el.xml");
 $tree=$document->__get_xhtml_tree();
 tool_tree::cleantreexhtml($tree);
 //echo tool_tree::tree_xhtml2xhtml($tree);
 $structure=$document->__get_structure();
 $signature=$structure->__get_signature();
 tool_tree::cleanstructure($signature);

 $test=new RecursiveIteratorIterator($tree,RecursiveIteratorIterator::SELF_FIRST);

 $chunker=new chunker();

 foreach($test as $id=>$tree){
   if($tree->__is_bloc_min()){
    $tree_texte=tool_tree::tree_xhtml2texte($tree);
    //echo tool_tree::tree_xhtml2signature($tree);
    $chunker->__init($tree_texte);
    echo "\n\n";
   }
 } 


// echo tool_tree::structure2texte($signature);

// echo tool_tree::tree_xhtml2texte($signature->__get_value());


die();
 
 $test=new RecursiveIteratorIterator($tree,RecursiveIteratorIterator::SELF_FIRST);

 foreach($test as $son){
    $value=$son->__get_value();
    $idn=$son->__get_idn();
    if($value instanceof Tag_str){
      $str=$value->__get_array_attributes();
      $seg_start=tool_string::get_all_segments($str,"#start");
      $seg_space=tool_string::get_all_segments($str," ");
      $seg_end=tool_string::get_all_segments($str,"#end");
      $all_seg=array_merge($seg_start,$seg_space,$seg_end);
      $all_seg=tool_string::array_segment_clean($all_seg);
      $all_words=tool_string::get_all_segments_bar($str,$all_seg,$idn);
      foreach($all_words["dictionnaire"] as $k=>$w){
        echo "$k\n";
        foreach($w as $a) echo "    $a\n";
      }
      //print_r($all_seg);
    }
 }


  //$segment_start=tool_string();

//  $all_segment=array_merge(get_all_segments($_str,"#start"),get_all_segments($_str," "),get_all_segments($_str,"#end"));




?>
